package com.example.SocialApplication.db.entity;

import com.example.SocialApplication.HelperFactory;
import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.field.ForeignCollectionField;
import com.j256.ormlite.table.DatabaseTable;

import java.io.Serializable;
import java.sql.SQLException;
import java.util.Collection;

import javax.management.relation.Role;

@DatabaseTable(tableName = "list_things")
public class ListThings implements Serializable {

    @DatabaseField(columnName = "id", generatedId = true, canBeNull = false, dataType = DataType.INTEGER)
    private int id;
    @DatabaseField(columnName = "name", canBeNull = false, dataType = DataType.STRING)
    private String name;
    @DatabaseField(columnName = "picture_id", canBeNull = true, dataType = DataType.STRING)
    private String pictureId;
//    @DatabaseField(columnName = "color", canBeNull = true, dataType = DataType.INTEGER)
    @DatabaseField(foreign = true)
    private ColorEntity color;
    @DatabaseField(columnName = "publicity", canBeNull = false, dataType = DataType.INTEGER)
    private int publicity;
    @DatabaseField(columnName = "demonstration", canBeNull = false, dataType = DataType.INTEGER)
    private int demonstration;
    @ForeignCollectionField(eager = true)
    private Collection<Thing> things;
    private User user;

    public ListThings() {

    }

    public ListThings(String name) {
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPictureId() {
        return pictureId;
    }

    public void setPictureId(String pictureId) {
        this.pictureId = pictureId;
    }

    public ColorEntity getColor() {
        return color;
    }

    public void setColor(ColorEntity color) {
        this.color = color;
    }

    public int getPublicity() {
        return publicity;
    }

    public void setPublicity(int publicity) {
        this.publicity = publicity;
    }

    public int getDemonstration() {
        return demonstration;
    }

    public void setDemonstration(int demonstration) {
        this.demonstration = demonstration;
    }

    public Collection<Thing> getThings() {
        return things;
    }

    public void setThings(Collection<Thing> things) {
        this.things = things;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

//    public void addThing(Thing value) throws SQLException {
//        value.setListThings(this);
//        HelperFactory.getHelper().getThingDAO().create(value);
//        things.add(value);
//    }
//
//    public void removeThing(Thing value) throws SQLException {
//        things.remove(value);
//        HelperFactory.getHelper().getThingDAO().delete(value);
//    }
}
